<?php
/**
 * Author Yulin
 * Email  dwzhanglong@126.com
 * Date   2017-9-19
 * Func   北京PK拾
 */
defined('IN_YuLin') || exit('NO PERMIT!');

//	返回中奖金额	data为订单信息，plays为玩法

function PrizeCount_3($data,$plays)
{
	if(!$data || !$data['result'] || !$plays)
	{
		return 0;
	}
	
	//	玩法
	$result = explode(',',$data['result']);
	
	//	猜冠军
	if($plays['playid'] == 21120)
	{
		$tmp = explode(',',$data['rednum']);
		
		return in_array($result[0],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	猜前二复式
	if($plays['playid'] == 21121)
	{
		$tmp = explode('|',$data['rednum']);
		$tmp[0] = explode(',',$tmp[0]);
		$tmp[1] = explode(',',$tmp[1]);
		
		return in_array($result[0],$tmp[0]) && in_array($result[1],$tmp[1]) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	猜前二单式
	if($plays['playid'] == 24188)
	{
		$tmp3 = 0;	//	中奖个数
		$tmp2 = $result[0].$result[1];
		$tmp = explode('_',$data['rednum']);
		foreach($tmp as $t)
		{
			$t == $tmp2 && $tmp3++;
		}
		
		return $tmp3 * $plays['maxprize'] * $data['times'];
	}
	
	//	猜前三复式
	if($plays['playid'] == 21122)
	{
		$tmp = explode('|',$data['rednum']);
		$tmp[0] = explode(',',$tmp[0]);
		$tmp[1] = explode(',',$tmp[1]);
		$tmp[2] = explode(',',$tmp[2]);
		
		return in_array($result[0],$tmp[0]) && in_array($result[1],$tmp[1]) && in_array($result[2],$tmp[2]) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	猜前三单式
	if($plays['playid'] == 24190)
	{
		$tmp3 = 0;	//	中奖个数
		$tmp2 = $result[0].$result[1].$result[2];
		$tmp = explode('_',$data['rednum']);
		foreach($tmp as $t)
		{
			$t == $tmp2 && $tmp3++;
		}
		
		return $tmp3 * $plays['maxprize'] * $data['times'];
	}
	
	//	猜前四复式
	if($plays['playid'] == 21123)
	{
		$tmp = explode('|',$data['rednum']);
		$tmp[0] = explode(',',$tmp[0]);
		$tmp[1] = explode(',',$tmp[1]);
		$tmp[2] = explode(',',$tmp[2]);
		$tmp[3] = explode(',',$tmp[3]);
		
		return in_array($result[0],$tmp[0]) && in_array($result[1],$tmp[1]) && in_array($result[2],$tmp[2]) && in_array($result[3],$tmp[3]) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	猜前四单式
	if($plays['playid'] == 24193)
	{
		$tmp3 = 0;	//	中奖个数
		$tmp2 = $result[0].$result[1].$result[2].$result[3];
		$tmp = explode('_',$data['rednum']);
		foreach($tmp as $t)
		{
			$t == $tmp2 && $tmp3++;
		}
		
		return $tmp3 * $plays['maxprize'] * $data['times'];
	}
	
	//	猜前五复式
	if($plays['playid'] == 21124)
	{
		$tmp = explode('|',$data['rednum']);
		$tmp[0] = explode(',',$tmp[0]);
		$tmp[1] = explode(',',$tmp[1]);
		$tmp[2] = explode(',',$tmp[2]);
		$tmp[3] = explode(',',$tmp[3]);
		$tmp[4] = explode(',',$tmp[4]);
		
		return in_array($result[0],$tmp[0]) && in_array($result[1],$tmp[1]) && in_array($result[2],$tmp[2]) && in_array($result[3],$tmp[3]) && in_array($result[4],$tmp[4]) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	猜前五单式
	if($plays['playid'] == 24197)
	{
		$tmp3 = 0;	//	中奖个数
		$tmp2 = $result[0].$result[1].$result[2].$result[3].$result[4];
		$tmp = explode('_',$data['rednum']);
		foreach($tmp as $t)
		{
			$t == $tmp2 && $tmp3++;
		}
		
		return $tmp3 * $plays['maxprize'] * $data['times'];
	}
	
	//	定位胆一
	$tmp = explode('|',$data['rednum']);
	if($plays['playid'] == 23625)
	{
		return in_array($result[0],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	定位胆二
	$tmp = explode('|',$data['rednum']);
	if($plays['playid'] == 23626)
	{
		return in_array($result[1],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	定位胆三
	$tmp = explode('|',$data['rednum']);
	if($plays['playid'] == 23627)
	{
		return in_array($result[2],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	定位胆四
	$tmp = explode('|',$data['rednum']);
	if($plays['playid'] == 23628)
	{
		return in_array($result[3],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	定位胆五
	$tmp = explode('|',$data['rednum']);
	if($plays['playid'] == 23629)
	{
		return in_array($result[4],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	定位胆六
	$tmp = explode('|',$data['rednum']);
	if($plays['playid'] == 23630)
	{
		return in_array($result[5],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	定位胆七
	$tmp = explode('|',$data['rednum']);
	if($plays['playid'] == 23631)
	{
		return in_array($result[6],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	定位胆八
	$tmp = explode('|',$data['rednum']);
	if($plays['playid'] == 23632)
	{
		return in_array($result[7],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	定位胆九
	$tmp = explode('|',$data['rednum']);
	if($plays['playid'] == 23633)
	{
		return in_array($result[8],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	定位胆十
	$tmp = explode('|',$data['rednum']);
	if($plays['playid'] == 23634)
	{
		return in_array($result[9],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	return 0;
}